package com.itita.ww2.utils;

public class DevKeyUtil {
	private static final String mySplit = ":";

	/**
	 * 组合str
	 */
	public static final String combineKey(Object... keys) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < keys.length; ++i) {
			if (keys[i] instanceof String[]) {
				String[] keysList = (String[]) keys[i];
				for (int j = 0; j < keysList.length; ++j) {
					sb.append(keysList[j]);
					if (j != keysList.length - 1) {
						sb.append(mySplit);
					}
				}
			} else {
				sb.append(keys[i]);
				if (i != keys.length - 1) {
					sb.append(mySplit);
				}
			}
		}
		return sb.toString();
	}

	/**
	 * 分离key并取得值
	 */
	public static final String splitKey(String devKey, int index) {
		String[] keys = devKey.split(mySplit);
		if (index > keys.length - 1) {
			return "";
		}
		return keys[index];
	}
}
